package com.ruoyi.partybuilding.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.partybuilding.common.EQueryController;
import com.ruoyi.partybuilding.common.PageSort;
import com.ruoyi.partybuilding.common.TableDataInfoRows;
import com.ruoyi.partybuilding.domain.MallPoints;
import com.ruoyi.partybuilding.domain.MallPoints;
import com.ruoyi.partybuilding.service.impl.MallPointsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(tags = "商城积分")
@RestController
@RequestMapping("/partybuilding/MallPoints")
public class MallPointsController extends EQueryController<MallPoints>
{
    @Resource
    MallPointsServiceImpl mallPointsService;
    /**
     * 查询列表
     */
    @Anonymous
    @ApiOperation("列表")
    @PreAuthorize("@ss.hasPermi('partybuilding:MallPoints:list')")
    @GetMapping("/list")
    public TableDataInfoRows<MallPoints> list(MallPoints entity, PageSort page) {
        return super.list(entity, page);
    }
    @Anonymous
    @ApiOperation("列表-当前登录用户")
    @PreAuthorize("@ss.hasPermi('partybuilding:MallPoints:query')")
    @GetMapping("/listByUser")
    public TableDataInfoRows<MallPoints> listByUser(MallPoints entity, PageSort page) {
        entity.setUserId(getUserId());
        return super.list(entity, page);
    }
    @Anonymous
    @ApiOperation("用户最新积分信息")
    @PreAuthorize("@ss.hasPermi('partybuilding:MallPoints:query')")
    @GetMapping("/topPoints")
    public R<MallPoints> topPoints() {
        return R.ok(mallPointsService.topPoints(getUserId()));
    }

    /**
     * 获取详细信息
     */
    @ApiOperation("详情")
    @PreAuthorize("@ss.hasPermi('partybuilding:MallPoints:query')")
    @GetMapping(value = "/{id}")
    public R<MallPoints> getInfo(@PathVariable("id") Long id)
    {
        return super.getInfo(id);
    }
}
